package com.fs.controller;

import com.fs.pojo.GoodsCategory;
import com.fs.vo.SysResult;
import com.fs.annotation.SysLog;
import com.fs.pojo.Goods;
import com.fs.service.GoodsCategorySerivce;
import com.fs.service.GoodsSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "商品分类管理")
@RestController
@RequestMapping("/goodsCate")
public class GoodsCategoryController {
    @Autowired
    private GoodsCategorySerivce goodsCategorySerivce;

//    @PostMapping("/add")
//    public ResultVO add(@RequestBody GoodsCategoryEntity entity){
//        return goodsCategorySerivce.add(entity);
//    }
//
//    @PutMapping("/edit")
//    public ResultVO edit(@RequestBody GoodsCategoryEntity entity){
//        return goodsCategorySerivce.edit(entity);
//    }
//
//    @GetMapping("/list")
//    public ResultVO list(CommRequestVO request){
//        return goodsCategorySerivce.list(request);
//    }
//
//    @DeleteMapping("/{id}")
//    public ResultVO deleteById(@PathVariable("id") Integer id){
//        return goodsCategorySerivce.delById(id);
//    }

    @SysLog("商品分类列表")
    @ApiOperation(value = "商品分类列表")
    @RequiresPermissions({"goods:cate:list"})
    @GetMapping("/findItemCatList/{level}")
    public SysResult findItemCatList(@PathVariable Integer level){
        return goodsCategorySerivce.findItemCatList(level);
    }

    @SysLog("修改商品分类状态")
    @ApiOperation(value = "修改商品分类状态")
    @RequiresPermissions({"goods:cate:status"})
    @PutMapping("/status/{id}/{status}")
    public SysResult updateStatus(GoodsCategory itemCat){
        return goodsCategorySerivce.updateStatus(itemCat);
    }

    @SysLog("修改商品分类")
    @ApiOperation(value = "修改商品分类")
    @RequiresPermissions({"goods:cate:update"})
    @PutMapping("/updateItemCat")
    public SysResult updateItemCat(@RequestBody GoodsCategory itemCat){
        return goodsCategorySerivce.updateItemCat(itemCat);
    }

    @SysLog("添加商品分类")
    @ApiOperation(value = "添加商品分类")
    @RequiresPermissions({"goods:cate:save"})
    @PostMapping("/saveItemCat")
    public SysResult saveItemCat(@RequestBody GoodsCategory itemCat){
        return goodsCategorySerivce.saveItemCat(itemCat);
    }

    @SysLog("删除商品分类")
    @ApiOperation(value = "删除商品分类")
    @RequiresPermissions({"goods:cate:del"})
    @DeleteMapping("/deleteItemCat")
    public SysResult deleteItemCat(GoodsCategory itemCat){
        return goodsCategorySerivce.deleteItemCat(itemCat);
    }

}
